<template>
  <a-card :bordered='false' class='card-area'>
    <!-- 查询区域 11111-->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' :label-col='labelCol' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :md='6' :sm='8'>
            <a-form-item label='会员名称'>
              <a-input placeholder='请输入会员名称' v-model='queryParam.memberName'></a-input>
            </a-form-item>
          </a-col>
          <a-col :md='6' :sm='8'>
            <a-form-item label='商户订单号'>
              <a-input placeholder='请输入商户订单号' v-model='queryParam.orderNo'></a-input>
            </a-form-item>
          </a-col>
          <a-col :md='5' :sm='8'>
            <a-form-item label='服务状态'>
              <a-select v-model='queryParam.orderStatus' placeholder='请选择服务状态'>
                <a-select-option value=''>请选择</a-select-option>
                <a-select-option value='1'>待接订单</a-select-option>
                <a-select-option value='2'>待服务</a-select-option>
                <a-select-option value='3'>服务中</a-select-option>
                <a-select-option value='4'>待评价</a-select-option>
                <a-select-option value='5'>已评价</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md='6' :sm='8'>
            <a-form-item label='项目名称'>
              <a-input placeholder='请输入项目名称' v-model='queryParam.project'></a-input>
            </a-form-item>
          </a-col>
          <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
           <a-col :md='6' :sm='24'>
               <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
               <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <a-button @click='handleAdd' type='primary' icon='plus'>新增</a-button>
      <a-dropdown v-if='selectedRowKeys.length > 0'>
        <a-menu slot='overlay'>
          <a-menu-item key='1' @click='batchDel'>
            <a-icon type='delete' />
            删除
          </a-menu-item>
        </a-menu>
        <a-button style='margin-left: 8px'> 批量操作
          <a-icon type='down' />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i>
        <span>已选择</span>
        <a style='font-weight: 600'>
          {{ selectedRowKeys.length }}
        </a>
        <span>项</span>
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        :scroll="{x:1500}"
        @change='handleTableChange'>

        <span slot='action' slot-scope='text, record'>
          <a @click='postSubmit(record.id,"确认接单","/store/order/service/confirm")' v-if='record.confirmStatus==1'>确认</a>

          <a @click='postSubmit(record.id,"确认完成","/store/order/service/finish")' v-if='record.confirmStatus==2'>执行完成</a>
          <a-divider type='vertical' v-if='record.confirmStatus==2'/>

          <a @click="handleTrack(record)"  v-if='record.confirmStatus!=1'>订单跟踪</a>

          <a-divider type='vertical' v-if="(record.payStatus==='3'||record.payStatus==='8')&&
(record.confirmStatus==1||record.confirmStatus==2|| record.confirmStatus==3)"/>
          <a @click="postSubmit(record.id,'确定申请退款吗','/store/order/order/refund')"
             v-if="(record.payStatus==='3'||record.payStatus==='8')&&
(record.confirmStatus==1||record.confirmStatus==2|| record.confirmStatus==3)">退款申请</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <HChCareDoorOrder-modal ref='modalForm' @ok='modalFormOk'></HChCareDoorOrder-modal>
    <HChCareDoorOrderTrack-modal ref="modalTrackForm" @ok="modalFormOk"></HChCareDoorOrderTrack-modal>
  </a-card>
</template>
<script>
import '@assets/less/TableExpand.less'
import HChCareDoorOrderModal from '../../../order/modules/HChCareDoorOrderModal'
import HChCareDoorOrderTrackModal from '../../../order/modules/HChCareDoorOrderTrackModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { putAction, getAction, postAction } from '@api/manage'
import { frozenBatch } from '@api/api'

export default {
  name: 'h_ch_care_door_orderList',
  mixins: [JeecgListMixin],
  components: {
    HChCareDoorOrderModal,
    HChCareDoorOrderTrackModal
  },
  data() {
    return {
      description: '上门服务订单管理页面',
      labelCol: { style: { width: '110px' } },
      queryParam:{
         //3上门护理 4上门照护 5陪诊服务 6慢性康复 7营养指导  10慢性
        orderType:"3"
      },
      // 表头
      columns: [
        {
          title: '订单号',
          align: 'center',
          dataIndex: 'orderSn',
          width: 150,
        },
        {
          title: '下单会员',
          align: 'center',
          dataIndex: 'memberName',
          width: 130,
        },
        {
          title: '被服务对像/年龄',
          align: 'center',
          dataIndex: 'patientName',
          width: 150,
          customRender: function(t, r, index) {
            return r.patientName+"/"+r.patientAge
          }
        },
        {
          title: '支付状态',
          align: 'center',
          dataIndex: 'payStatus_dictText',
          width: 100,
        },
        {
          title: '项目分类',
          align: 'center',
          dataIndex: 'categoryName',
          width: 130,
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'project',
          width: 150,
        },
        {
          title: '总费用(元)',
          align: 'center',
          dataIndex: 'amount',
          width: 100,
        },
        {
          title: '服务时间',
          align: 'center',
          dataIndex: 'appointmentDate',
          width: 120,
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark',
          width: 100,
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime',
          width: 130,
        },
        {
          title: '确认状态',
          align: 'center',
          dataIndex: 'confirmStatus_dictText',
          width: 100,
        },
        {
          title: '确认姓名',
          align: 'center',
          dataIndex: 'confirmUser',
          width: 130,
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
          fixed:"right",
          width: 220,
        }
      ],
      url: {
        list: '/store/order/service/list',
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    handleTrack: function (record) {
      this.$refs.modalTrackForm.edit(record);
      this.$refs.modalTrackForm.title = "查看";
      this.$refs.modalTrackForm.disableSubmit = false;
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>